<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="css/element.css" rel="stylesheet"/>
    <link href="css/styleindex.css" rel="stylesheet"/>
    <style>

    </style>
</head>
<body style="background: #ffffff;">

  <div class="mui-content" style="margin-top:30px;">
    <div id="vm" class="x-examok" v-cloak>

    </div>
  </div>

  <script type="text/javascript" src="./script/vue.js"></script>
  <script type="text/javascript" src="./script/element.js"></script>
  <script type="text/javascript" src="./script/api.js"></script>
  <script type="text/javascript" src="./script/base.js"></script>
	<script>
  var frameIndex=0;
apiready = function () {
    var iostoph = api.safeArea.top + 44;
    // console.log(iostoph);
    api.setStatusBarStyle({
      style: 'dark'
    });
    //
    api.addEventListener({
        name: 'loginsucc'
    }, function(ret, err) {
      api.setFrameGroupIndex({
          name: 'openhomecard',
          index: 0
      });
      var NVTabBar = api.require('NVTabBar');
      NVTabBar.setSelect({
            index: 0,
            selected: true
      });
      vm.openindexframe()
    });
    //退出登录
    api.addEventListener({
      name: 'changeinfo'
    }, function(ret, err) {
        api.closeFrameGroup({
            name: 'openhomecard'
        });
        var NVTabBar = api.require('NVTabBar');
        NVTabBar.close();
    });
    //
    api.addEventListener({
      name: 'keyback'
    }, function(ret, err) {

    });
    // 设置应用模糊效果：
    api.addEventListener({
       name: 'pause'
    }, function(){
       api.setBlurEffect({
           style: 'light',
           global: true
       });
    });

    api.addEventListener({
       name: 'resume'
    }, function(){
       api.setBlurEffect({
           style: 'none',
           global: true
       });
    });
    //  $api.setStorage('apptoken','');
    //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
          company:'',
          username:'',
          store:'',
          jobs:'',
          leveltitle:'',
          avatar:'',

        }
      },
      created:function() {
        var that=this;


      },
      mounted:function(){
        var that=this;
        that.openindexframe()//打开首页页面frame
      },
      methods: {
        //打开首页页面frame
        openindexframe:function(){
          var that = this;
          var applimits = $api.getStorage('applimits');
        //   console.log(applimits);
          if(applimits=='1'){//总部
            var framesbase=[{
                name: 'z_study',
                url: 'z_study.html',
                bgColor: '#fff',
                bounces:false
            },  
            {
                name: 'task',
                url: 'task.html',
                bgColor: '#fff',
                bounces:false
            },
            {
                name: 'z_work',
                url: 'z_work.html',
                bgColor: '#fff',
                bounces:false
            }, {
                name: 'z_my',
                url: 'z_my.html',
                bgColor: '#fff',
                bounces:true,
            }]
          }else{//门店
            var framesbase = [{
                name: 'study',
                url: 'study.html',
                bgColor: '#fff',
                bounces:false
            },  {
                name: 'zhtask',
                url: 'zh_task.html',
                bgColor: '#fff',
                bounces:false
            },{
                name: 'work',
                url: 'work.html',
                bgColor: '#fff',
                bounces:false
            }, {
                name: 'my',
                url: 'my.html',
                bgColor: '#fff',
                bounces:true,
            }]
          }
        //   console.log(JSON.stringify(framesbase));
          // 选项卡内容
          api.openFrameGroup({
              name: 'openhomecard',
              background: '#fff',
              rect: {
                 marginLeft:0,
                 marginTop:0,
                 marginBottom:54,
                 marginRight:0
              },
              frames: framesbase,
              preload:3,
              index:frameIndex,
              scrollEnabled:false//滑动
          }, function(ret, err) {
              // console.log("openFrameGroup的ret"+JSON.stringify(ret))
              var index = ret.index;
              if(ret){
                that.NVNavigationBar_open(index);
              }
          });
        },
        //加载底部选项卡
        NVNavigationBar_open:function(index) {
          var applimits = $api.getStorage('applimits');
          if(applimits=='1'){//总部
            var itemsframes = [{
                  w: api.winWidth / 4.0,
                  iconRect: {
                      w: 25.0,
                      h: 25.0,
                  },
                  icon: {
                      normal: 'widget://image/icon11.png',
                      highlight: 'widget://image/icon1.png',
                      selected: 'widget://image/icon1.png'
                  },
                  title: {
                      text: '主页',
                      size: 12.0,
                      normal: '#999',
                      selected: '#058142',
                      marginB: 2.0,
                  }
              },
               {
                  w: api.winWidth / 4.0,
                  iconRect: {
                      w: 25.0,
                      h: 25.0,
                  },
                  icon: {
                      normal: 'widget://image/icon22.png',
                      highlight: 'widget://image/icon2.png',
                      selected: 'widget://image/icon2.png'
                  },
                  title: {
                      text: '任务栏',
                      size: 12.0,
                      normal: '#999',
                      selected: '#058142',
                      marginB: 2.0
                  }
              }, 
              {
                  w: api.winWidth / 4.0,
                  iconRect: {
                      w: 25.0,
                      h: 25.0,
                  },
                  icon: {
                      normal: 'widget://image/icon33.png',
                      highlight: 'widget://image/icon3.png',
                      selected: 'widget://image/icon3.png'
                  },
                  title: {
                      text: '工作台',
                      size: 12.0,
                      normal: '#999',
                      selected: '#058142',
                      marginB: 2.0
                  }
              }, {
                  w: api.winWidth / 4.0,
                  iconRect: {
                      w: 25.0,
                      h: 25.0,
                  },
                  icon: {
                      normal: 'widget://image/icon44.png',
                      highlight: 'widget://image/icon4.png',
                      selected: 'widget://image/icon4.png'
                  },
                  title: {
                      text: '我的',
                      size: 12.0,
                      normal: '#999',
                      selected: '#058142',
                      marginB: 2.0
                  }
              }]
          }else{//门店
            var  itemsframes = [{
                  w: api.winWidth / 4.0,
                  iconRect: {
                      w: 25.0,
                      h: 25.0,
                  },
                  icon: {
                      normal: 'widget://image/icon11.png',
                      highlight: 'widget://image/icon1.png',
                      selected: 'widget://image/icon1.png'
                  },
                  title: {
                      text: '主页',
                      size: 12.0,
                      normal: '#999',
                      selected: '#058142',
                      marginB: 2.0,
                  }
              },
               {
                  w: api.winWidth / 4.0,
                  iconRect: {
                      w: 25.0,
                      h: 25.0,
                  },
                  icon: {
                      normal: 'widget://image/icon22.png',
                      highlight: 'widget://image/icon2.png',
                      selected: 'widget://image/icon2.png'
                  },
                  title: {
                      text: '任务栏',
                      size: 12.0,
                      normal: '#999',
                      selected: '#058142',
                      marginB: 2.0
                  }
              }, 
              {
                  w: api.winWidth / 4.0,
                  iconRect: {
                      w: 25.0,
                      h: 25.0,
                  },
                  icon: {
                      normal: 'widget://image/icon33.png',
                      highlight: 'widget://image/icon3.png',
                      selected: 'widget://image/icon3.png'
                  },
                  title: {
                      text: '工作台',
                      size: 12.0,
                      normal: '#999',
                      selected: '#058142',
                      marginB: 2.0
                  }
              }, {
                  w: api.winWidth / 4.0,
                  iconRect: {
                      w: 25.0,
                      h: 25.0,
                  },
                  icon: {
                      normal: 'widget://image/icon44.png',
                      highlight: 'widget://image/icon4.png',
                      selected: 'widget://image/icon4.png'
                  },
                  title: {
                      text: '我的',
                      size: 12.0,
                      normal: '#999',
                      selected: '#058142',
                      marginB: 2.0
                  }
              }]
          }
            var NVTabBar = api.require('NVTabBar');
            var that = this;
            NVTabBar.open({
              styles: {
                  bg: '#fff',
                  h: 54,
                  dividingLine: {
                      width: 0.5,
                      color: '#f5f5f5'
                  },
                  badge: {
                      bgColor: '#f00',
                      numColor: '#000',
                      size: 6.0,
                      centerY: 2
                  }
              },
              items: itemsframes,
              selectedIndex: 0
            }, function(ret, err) {
                // console.log("ret"+JSON.stringify(ret))
                if (ret.eventType == 'click') {
                  api.setFrameGroupIndex({
                            name: "openhomecard",
                            index: ret.index,
                            scroll: true
                        });
                }
                if (ret.eventType == "click" && ret.index == 0) {
                    // that.openindexframe()//打开首页
                    api.setFrameGroupAttr({
                        name: 'openworkgroupframe',
                        hidden: true
                    });
                    api.setFrameGroupAttr({
                        name: 'openworkgroupframetask',
                        hidden: true
                    });
                }
                if (ret.eventType == "click" && ret.index == 1) {
                    // that.opentaskframe()//打开任务栏
                    that.openworkFrameTask()//打开任务栏选项卡的页面
                    api.setFrameGroupAttr({
                        name: 'openworkgroupframe',
                        hidden: true
                    });
                }
                if (ret.eventType == "click" && ret.index == 2) {
                    // that.fnOpenNvnBar2()//打开工作台选项卡
                    if($api.getStorage('applimits')=='1'){//总部
                        api.setFrameGroupAttr({
                            name: 'openworkgroupframe',
                            hidden: true
                        });
                    }else{
                        that.openworkFrame()//打开工作台选项卡的页面
                        api.setFrameGroupAttr({
                            name: 'openworkgroupframetask',
                            hidden: true
                        });
                    }
                    
                    // api.setFrameGroupAttr({
                    //     name: 'openhomecard',
                    //     hidden: true
                    // });
                    // that.hideindex()//隐藏首页
                    // that.hidetask()//隐藏任务栏
                    // that.hidemy()//隐藏我的
                }
                if (ret.eventType == "click" && ret.index == 3) {
                    // that.openmyframe()//打开我的
                    api.setFrameGroupAttr({
                        name: 'openworkgroupframe',
                        hidden: true
                    });
                    api.setFrameGroupAttr({
                        name: 'openworkgroupframetask',
                        hidden: true
                    });
                }
            });
          },
          //隐藏首页
          hideindex:function(){
            api.setFrameAttr({
                name: 'study',
                hidden: true
            });
          },
          //隐藏任务栏
          hidetask:function(){
            api.setFrameAttr({
                name: 'task',
                hidden: true
            });
          },
          //隐藏wode
          hidemy:function(){
            api.setFrameAttr({
                name: 'my',
                hidden: true
            });
          },
          //打开工作台的选项卡
          fnOpenNvnBar2:function() {
              api.openFrame({
                  name: 'work',
                  url: 'work.html',
                  bounces: false,
                  rect: { // 推荐使用Margin布局，用于适配屏幕的动态变化
                    marginLeft:0,    //相对父页面左外边距的距离，数字类型
                    marginTop:0,     //相对父页面上外边距的距离，数字类型
                    marginBottom:54,  //相对父页面下外边距的距离，数字类型
                    marginRight:0    //相对父页面右外边距的距离，数字类型
                  }
              });
          },
          // 打开任务栏选项卡的页面
          openworkFrameTask:function(frameIndex){
            api.openFrameGroup({
                name: 'openworkgroupframetask',
                background: '#fff',
                rect: {
                   marginLeft:0,
                   marginTop:iostoph,
                   marginBottom:54+api.safeArea.bottom,
                   marginRight:0
                },
                frames: [{
                    name: 'task1',
                    url: './task/task1.html',
                    bgColor: '#fff',
                    bounces:false
                },  {
                    name: 'task2',
                    url: './task/task2.html',
                    bgColor: '#fff',
                    bounces:false
                },{
                    name: 'task3',
                    url: './task/task3.html',
                    bgColor: '#fff',
                    bounces:false
                },{
                    name: 'task4',
                    url: './task/task4.html',
                    bgColor: '#fff',
                    bounces:false
                },{
                    name: 'task5',
                    url: './task/task5.html',
                    bgColor: '#fff',
                    bounces:false
                },{
                    name: 'task6',
                    url: './task/task6.html',
                    bgColor: '#fff',
                    bounces:false
                },{
                    name: 'task7',
                    url: './task/task7.html',
                    bgColor: '#fff',
                    bounces:false
                },],
                preload:0,
                index:frameIndex,
                scrollEnabled:false//滑动
            }, function(ret, err) {
                // console.log("openFrameGroup的ret"+JSON.stringify(ret))
                var index = ret.index;
                if(ret){
                  // NVNavigationBar_open(index);
                  if (ret.index > -1) {
                    setTimeout(function(){
                      api.execScript({
                          frameName: 'zhtask',
                          script: 'fnNvnsetSelectedtask("' + ret.index + '");'
                      });
                    },500)

                  }
                }
            });
          },
          // 打开工作台选项卡的页面
          openworkFrame:function(frameIndex){
            api.openFrameGroup({
                name: 'openworkgroupframe',
                background: '#fff',
                rect: {
                   marginLeft:0,
                   marginTop:iostoph,
                   marginBottom:54+api.safeArea.bottom,
                   marginRight:0
                },
                frames: [{
                    name: 'work1',
                    url: 'work1.html',
                    bgColor: '#fff',
                    bounces:false
                },  {
                    name: 'work2',
                    url: 'work2.html',
                    bgColor: '#fff',
                    bounces:false
                },{
                    name: 'work3',
                    url: 'work3.html',
                    bgColor: '#fff',
                    bounces:false
                },
                {
                    name: 'work4',
                    url: 'work4.html',
                    bgColor: '#fff',
                    bounces:true,
                    pageParam:{
                
                    }
                },
                {
                    name: 'work5',
                    url: 'work5.html',
                    bgColor: '#fff',
                    bounces:true,
                    pageParam:{
                    }
                },{
                    name: 'work6',
                    url: 'work6.html',
                    bgColor: '#fff',
                    bounces:true,
                    pageParam:{
                    }
                }],
                preload:0,
                index:frameIndex,
                scrollEnabled:false//滑动
            }, function(ret, err) {
                // console.log("openFrameGroup的ret"+JSON.stringify(ret))
                var index = ret.index;
                if(ret){
                  // NVNavigationBar_open(index);
                  if (ret.index > -1) {
                    setTimeout(function(){
                      api.execScript({
                          frameName: 'work',
                          script: 'fnNvnsetSelected("' + ret.index + '");'
                      });
                    },500)

                  }
                }
            });
          }
      }
    })


	}
  //
  function fnsetFrameGroupIndex(name, index) {
      api.setFrameGroupIndex({
          name: name,
          index: index,
          scroll: true
      });
  }

	</script>
</body>
</html>
